/*
 * Copyright 2025 Nimtable
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */


// This file is auto-generated by @hey-api/openapi-ts

import type { Options as ClientOptions, TDataShape, Client } from '@hey-api/client-fetch';
import type { GetCatalogsData, GetCatalogsResponse, GetCatalogsError, CreateCatalogData, CreateCatalogResponse, CreateCatalogError, DeleteCatalogData, DeleteCatalogResponse, DeleteCatalogError, GetTableInfoData, GetTableInfoResponse, GetTableInfoError, CreateScheduledTaskData, CreateScheduledTaskResponse, CreateScheduledTaskError, GetScheduledTasksData, GetScheduledTasksResponse, GetScheduledTasksError, DeleteScheduledTaskData, DeleteScheduledTaskResponse, DeleteScheduledTaskError, GetScheduledTaskData, GetScheduledTaskResponse, GetScheduledTaskError, ToggleScheduledTaskData, ToggleScheduledTaskResponse, ToggleScheduledTaskError, GetSystemInfoData, GetSystemInfoResponse, GetSystemInfoError } from './types.gen';
import { client as _heyApiClient } from './client.gen';

export type Options<TData extends TDataShape = TDataShape, ThrowOnError extends boolean = boolean> = ClientOptions<TData, ThrowOnError> & {
    /**
     * You can provide a client instance returned by `createClient()` instead of
     * individual options. This might be also useful if you want to implement a
     * custom client.
     */
    client?: Client;
    /**
     * You can pass arbitrary values through the `meta` object. This can be
     * used to access values that aren't defined as part of the SDK function.
     */
    meta?: Record<string, unknown>;
};

/**
 * Get all catalogs
 * Returns a list of all catalogs
 */
export const getCatalogs = <ThrowOnError extends boolean = false>(options?: Options<GetCatalogsData, ThrowOnError>) => {
    return (options?.client ?? _heyApiClient).get<GetCatalogsResponse, GetCatalogsError, ThrowOnError>({
        security: [
            {
                scheme: 'bearer',
                type: 'http'
            }
        ],
        url: '/api/catalogs',
        ...options
    });
};

/**
 * Create new catalog
 * Creates a new catalog
 */
export const createCatalog = <ThrowOnError extends boolean = false>(options: Options<CreateCatalogData, ThrowOnError>) => {
    return (options.client ?? _heyApiClient).post<CreateCatalogResponse, CreateCatalogError, ThrowOnError>({
        security: [
            {
                scheme: 'bearer',
                type: 'http'
            }
        ],
        url: '/api/catalogs',
        ...options,
        headers: {
            'Content-Type': 'application/json',
            ...options?.headers
        }
    });
};

/**
 * Delete catalog
 * Deletes a specific catalog
 */
export const deleteCatalog = <ThrowOnError extends boolean = false>(options: Options<DeleteCatalogData, ThrowOnError>) => {
    return (options.client ?? _heyApiClient).delete<DeleteCatalogResponse, DeleteCatalogError, ThrowOnError>({
        security: [
            {
                scheme: 'bearer',
                type: 'http'
            }
        ],
        url: '/api/catalogs/{catalogName}',
        ...options
    });
};

/**
 * Get table information
 * Returns detailed information about a specific table including metadata and snapshots
 */
export const getTableInfo = <ThrowOnError extends boolean = false>(options: Options<GetTableInfoData, ThrowOnError>) => {
    return (options.client ?? _heyApiClient).get<GetTableInfoResponse, GetTableInfoError, ThrowOnError>({
        security: [
            {
                scheme: 'bearer',
                type: 'http'
            }
        ],
        url: '/api/catalog/{catalog}/v1/namespaces/{namespace}/tables/{table}',
        ...options
    });
};

/**
 * Create or update scheduled task
 * Creates a new scheduled task or updates an existing one for table optimization
 */
export const createScheduledTask = <ThrowOnError extends boolean = false>(options: Options<CreateScheduledTaskData, ThrowOnError>) => {
    return (options.client ?? _heyApiClient).post<CreateScheduledTaskResponse, CreateScheduledTaskError, ThrowOnError>({
        security: [
            {
                scheme: 'bearer',
                type: 'http'
            }
        ],
        url: '/api/optimize/{catalog}/{namespace}/{table}/schedule',
        ...options,
        headers: {
            'Content-Type': 'application/json',
            ...options?.headers
        }
    });
};

/**
 * Get all scheduled tasks
 * Returns a list of all scheduled optimization tasks
 */
export const getScheduledTasks = <ThrowOnError extends boolean = false>(options?: Options<GetScheduledTasksData, ThrowOnError>) => {
    return (options?.client ?? _heyApiClient).get<GetScheduledTasksResponse, GetScheduledTasksError, ThrowOnError>({
        security: [
            {
                scheme: 'bearer',
                type: 'http'
            }
        ],
        url: '/api/optimize/scheduled-tasks',
        ...options
    });
};

/**
 * Delete scheduled task
 * Deletes a specific scheduled task
 */
export const deleteScheduledTask = <ThrowOnError extends boolean = false>(options: Options<DeleteScheduledTaskData, ThrowOnError>) => {
    return (options.client ?? _heyApiClient).delete<DeleteScheduledTaskResponse, DeleteScheduledTaskError, ThrowOnError>({
        security: [
            {
                scheme: 'bearer',
                type: 'http'
            }
        ],
        url: '/api/optimize/scheduled-task/{id}',
        ...options
    });
};

/**
 * Get scheduled task by ID
 * Returns details of a specific scheduled task
 */
export const getScheduledTask = <ThrowOnError extends boolean = false>(options: Options<GetScheduledTaskData, ThrowOnError>) => {
    return (options.client ?? _heyApiClient).get<GetScheduledTaskResponse, GetScheduledTaskError, ThrowOnError>({
        security: [
            {
                scheme: 'bearer',
                type: 'http'
            }
        ],
        url: '/api/optimize/scheduled-task/{id}',
        ...options
    });
};

/**
 * Toggle scheduled task
 * Enable or disable a scheduled task
 */
export const toggleScheduledTask = <ThrowOnError extends boolean = false>(options: Options<ToggleScheduledTaskData, ThrowOnError>) => {
    return (options.client ?? _heyApiClient).put<ToggleScheduledTaskResponse, ToggleScheduledTaskError, ThrowOnError>({
        security: [
            {
                scheme: 'bearer',
                type: 'http'
            }
        ],
        url: '/api/optimize/scheduled-task/{id}/toggle',
        ...options,
        headers: {
            'Content-Type': 'application/json',
            ...options?.headers
        }
    });
};

/**
 * Get system information
 * Returns system information including CPU count and memory details
 */
export const getSystemInfo = <ThrowOnError extends boolean = false>(options?: Options<GetSystemInfoData, ThrowOnError>) => {
    return (options?.client ?? _heyApiClient).get<GetSystemInfoResponse, GetSystemInfoError, ThrowOnError>({
        security: [
            {
                scheme: 'bearer',
                type: 'http'
            }
        ],
        url: '/api/optimize/system-info',
        ...options
    });
};